function safety = checkSafety(p,nodeA,nodeB,nodeC)

T = [nodeA; nodeB; nodeC];
A = det([ones(3,1) T(:,2:3)]);
B = det([T(:,1) ones(3,1) T(:,3)]);
C = det([T(:,1:2) ones(3,1)]);
D = -det([T(:,1:3)]);

z = (-D-A*p(1)-B*p(2))/C;
safety = p(3) - z;
% safety = (A*p(1)+B*p(2)+C*p(3)+D)*C > 0;
end